import {defHttp} from '/@/utils/http/axios';
import { Modal } from "ant-design-vue";

export enum Api {
  //开票申请 - 列表 -------------------------------------
  openAccountList   = '/invoiceList/openAccountList',
  //申请开票 - 勾选
  invoiceListSubmit = '/invoiceFlow/invoiceListSubmit',
  //申请开票 - 保存
  invoiceOrderSave  = '/invoiceOrder/save',
  //申请开票 - 特殊
  invoiceOrderSaveTsbill  = '/invoiceOrder/saveTsbill',
  //申请开票 - 特殊 - 公司信息
  invoiceCompanyInfo  = '/invoiceCompanyController/ajaxAutocomplete',

  //开票审核 - 列表 -------------------------------------
  openOrderList     = '/invoiceOrder/dataGrid?type=open',
  //开票审核 - 详细 - 票据申请 & 开票信息
  invoiceOrderById  = '/invoiceOrder/ajaxBusinessId',
  //开票审核 - 详细 - 项目收支
  invoiceFlowList   = '/invoiceFlow/ajaxFindOrderID',
  //开票审核 - 详细 - 发票信息
  invoiceInfoList   = '/invoiceInfo/ajaxBusinessAccountTable',

  //回票登记 - 列表 -------------------------------------
  backAccountList   = '/invoiceList/backAccountList',
  //回票审核 - 列表 -------------------------------------
  backOrderList     = '/invoiceOrder/dataGrid?type=back',

  //开票审核 - 详细 - 取消 && 完成审核
  ajaxBusinessStat  = '/invoiceOrder/ajaxBusinessStat',
  //开票审核 - 详细 - 票据申请 & 开票信息 - 修改
  invoiceOrderUpdate= '/invoiceOrder/update',
  //开票审核 - 详细 - 票据申请 & 开票信息 - 删除
  invoiceOrderDelete= '/invoiceOrder/ajaxBusinessDelete',

  //票据审核 - 收支明细 - 勾选 - 弹窗
  openAccountGridSelectModal  = '/invoiceFlow/invoiceSelect',
  //票据审核 - 收支明细 - 勾选 - 提交
  openAccountGridSelectSubmit = '/invoiceFlow/ajaxAccountOnTrustRefer',

  invoiceAccountDel = '/invoiceFlow/ajaxBatchDelete',

  invoiceInfoById = '/invoiceInfo/queryById',
  //票据审核 - 发标信息 - 添加
  invoiceInfoAdd = '/invoiceInfo/save',
  //票据审核 - 发标信息 - 修改
  invoiceInfoEdt = '/invoiceInfo/save',
  //票据审核 - 发标信息 - 删除
  invoiceInfoDel = '/invoiceInfo/ajaxBatchDelete',

  //开票审核
  exportXls = '/invoiceOrder/exportXls',
}

/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 开票申请 - 特殊
 * @param params
 */
export const openAccountList = (params) => defHttp.get({url: Api.openAccountList, params});

/**
 * 开票申请 - 勾选
 * @param params
 */
export const invoiceListSubmit = (params) => defHttp.get({url: Api.invoiceListSubmit, params}, {isTransformResponse:false});

/**
 * 开票申请 - 保存
 * @param params
 */
export const invoiceOrderSave = (params) => defHttp.post({ url: Api.invoiceOrderSave, params }, {isTransformResponse:false});

/**
 * 开票申请 - 特殊
 * @param params
 */
export const invoiceOrderSaveTsbill = (params) => defHttp.post({ url: Api.invoiceOrderSaveTsbill, params }, {isTransformResponse:false});

/**
 * 开票申请 - 特殊 - 公司信息
 * @param params
 */
export const invoiceCompanyInfo = (params) => defHttp.get({url: Api.invoiceCompanyInfo, params});

/**
 * 开票审核 - 列表
 * @param params
 */
export const openOrderList = (params) => defHttp.get({url: Api.openOrderList, params});

/**
 * 回票登记
 * @param params
 */
export const backAccountList = (params) => defHttp.get({url: Api.backAccountList, params});

/**
 * 回票审核
 * @param params
 */
export const backOrderList = (params) => defHttp.get({url: Api.backOrderList, params});

/**
 * 开票审核 - 详细
 * @param params
 */
export const invoiceOrderById = (params) => defHttp.get({url: Api.invoiceOrderById, params}, {isTransformResponse:false});

/**
 * 开票审核 - 详细
 * @param params
 */
export const invoiceFlowList = (params) => defHttp.get({url: Api.invoiceFlowList, params}, {isTransformResponse:false});

/**
 * 开票审核 - 发票
 * @param params
 */
export const invoiceInfoList = (params) => defHttp.get({url: Api.invoiceInfoList, params}, {isTransformResponse:false});

/**
 * 开票审核 - 添加 - 弹出窗体
 * @param params
 */
export const openAccountGridSelectModal = (params) => defHttp.get({url: Api.openAccountGridSelectModal, params}, {isTransformResponse:false});

/**
 * 开票申请 - 特殊
 * @param params
 */
export const openAccountGridSelectSubmit = (params) => defHttp.post({ url: Api.openAccountGridSelectSubmit, params }, {isTransformResponse:false});

/**
 * 开票审核 - 添加 - 删除
 * @param params
 */
export const invoiceAccountDel = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.invoiceAccountDel, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};

/**
 * 开票审核 - 详细 - 取消 && 完成审核
 * @param params
 */
export const ajaxBusinessStat = (params) => {
  return defHttp.post({url: Api.ajaxBusinessStat, params}, {isTransformResponse:false, joinParamsToUrl: true});
}

/**
 * 开票审核 - 详细 - 票据申请 & 开票信息 - 修改
 * @param params
 */
export const invoiceOrderUpdate = (params) => {
  return defHttp.post({url: Api.invoiceOrderUpdate, params}, {isTransformResponse:false});
}

/**
 * 开票审核 - 详细 - 票据申请 & 开票信息 - 删除
 * @param params
 */
export const invoiceOrderDelete = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除当前申请',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.invoiceOrderDelete, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};

export const invoiceInfoAdd = (params) => {
  return defHttp.post({url: Api.invoiceInfoAdd, params}, {isTransformResponse:false});
}

/**
 * 开票审核 - 发票
 * @param params
 */
export const invoiceInfoById = (params) => defHttp.get({url: Api.invoiceInfoById, params}, {isTransformResponse:false});


export const invoiceInfoEdt = (params) => {
  return defHttp.post({url: Api.invoiceInfoEdt, params}, {isTransformResponse:false});
}

/**
 * 开票审核 - 添加 - 删除
 * @param params
 */
export const invoiceInfoDel = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.invoiceInfoDel, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};
